/*
 * @Date: 2023-03-13 15:28:30
 * @LastEditors: Zireael 1193875164@qq.com
 * @LastEditTime: 2023-03-13 19:08:25
 * @FilePath: \A19\frontend\src\hooks\echarts\chartInitHook.ts
 */
import * as echarts from "echarts/core";
import {
  // 系列类型的定义后缀都为 SeriesOption
  BarSeriesOption,
  BarChart,
  LineSeriesOption,
  LineChart,
  PieChart,
  PieSeriesOption
} from "echarts/charts";
import {
  TitleComponent,
  // 组件类型的定义后缀都为 ComponentOption
  TitleComponentOption,
  TooltipComponent,
  TooltipComponentOption,
  GridComponent,
  GridComponentOption,
  // 数据集组件
  DatasetComponent,
  DatasetComponentOption,
  // 内置数据转换器组件 (filter, sort)
  TransformComponent,

  LegendComponent
} from "echarts/components";
import { LabelLayout, UniversalTransition } from "echarts/features";
import { CanvasRenderer } from "echarts/renderers";

type ECOption = echarts.ComposeOption<
  | BarSeriesOption
  | LineSeriesOption
  | TitleComponentOption
  | TooltipComponentOption
  | GridComponentOption
  | DatasetComponentOption
  | PieSeriesOption
>;

echarts.use([
  TitleComponent,
  TooltipComponent,
  GridComponent,
  DatasetComponent,
  TransformComponent,
  BarChart,
  LineChart,
  PieChart,
  LabelLayout,
  UniversalTransition,
  CanvasRenderer,
  LegendComponent,
]);

export { echarts, ECOption };
